<?php
/**
 * Created by PhpStorm.
 * User: zhangfulai
 * Date: 2018/10/8
 * Time: 上午10:26
 */
namespace app\api\model;
use think\Model;
class Message extends Model{
    protected function initialize()
    {
        //需要调用`Model`的`initialize`方法
        parent::initialize();
        //TODO:自定义的初始化
    }
    protected function getLastLoginTimeAttr($vlue){
        return date("Y-m-d H:i:s",$vlue);
    }
    protected function getUtimeAttr($vlue){
        return date("Y-m-d H:i:s",$vlue);
    }
    protected function getCtimeAttr($vlue){
        return date("Y-m-d H:i:s",$vlue);
    }
    public function addMessage($addarray){
        $result = $this
                ->insert($addarray);
        return $result;
    }
    public function messageList($pageNum,$listNum,$w){
        $result["list"] = $this
            ->where($w)
            ->page($pageNum,$listNum)
            ->order("ctime desc")
            ->select();
        $result["total"] = $this
            ->where($w)
            ->count("u_id");
        return $result;
    }
    public function changeMessage($w,$c){
        $result = $this
                ->where($w)
                ->update($c);
        return $result;
    }
}